/*
 * CAppStateGame.h
 *
 *  Created on: 25/12/2012
 *
 */

#ifndef CAPPSTATEGAME_H_
#define CAPPSTATEGAME_H_
#include "CAppState.h"
#include "CSurface.h"
#include "CNet.h"
#include <list>
#include <stack>
#include <string>
#include <SDL/SDL_ttf.h>
#include "SurfaceWrapper.h"
#include "DataLoader.h"
using namespace std;
#define LIFE 6


class CAppStateGame : public CAppState{
	private:
		static CAppStateGame instance;
		SDL_Surface* surface;
		CClientSocket* tcpClient;
		CNetMessage msg;
		TTF_Font* font;
		TTF_Font* fontWord;
		list<SurfaceWrapper> surfaceList;
		stack<SurfaceWrapper> bigDoll;
		stack<SurfaceWrapper> smallDoll;
		DataLoader* user;


		SDL_Surface* bigBar;
		SDL_Surface* smallBar;
		SDL_Surface* wrong;
		SDL_Surface* right;
		SDL_Surface* smallWrong;
		SDL_Surface* smallRight;
		SDL_Surface* player1name;
		SDL_Surface* player2name;

		string word;
		string tip;
		string usedLetters;
		string rightLetters;
		bool endGame;
		int life;

	private:
		CAppStateGame();
		void createUnderlines();
		void onKeyDown(SDLKey sym, SDLMod mod, Uint16 unicode);
		void drawPlayer2Wrong();
		void drawPlayer2Right(char letter);
		void hit();
		void miss();
		void loadDolls();
		string stringToUpper(string strToConvert);
	 public:
			void wait(int timeInSeconds);
	        void onActivate();

	        void onDeactivate();

	        void onLoop();

	        void onRender(SDL_Surface* surfDisplay);

	        void setUser(DataLoader* user){this->user = user; this->tcpClient = user->getClienteSocket();};
	        DataLoader* getUser(){return this->user;};
	        static CAppStateGame* getInstance();

};


#endif /* CAPPSTATEGAME_H_ */
